﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Documents;

namespace WpfAdornerDemo
{
    class CustomAdornerDecorator : Decorator
    {
        public CustomAdornerDecorator()
        {
            this.Loaded += OnAdornerLoaded;
        }

        private void OnAdornerLoaded(object sender, System.Windows.RoutedEventArgs e)
        {
            var layer = AdornerLayer.GetAdornerLayer(this);

            if (layer != null)
            {
                var adorner = new CustomAdorner(this);
                layer.Add(adorner);
            }
        }
    }
}
